﻿@using Microsoft.Web.Helpers
@model Domain.Entity.Game


@{
    ViewBag.Title = @Model.Name;
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<head>
<script type="text/javascript">
    function Rate(rating) {
        document.getElementById('rating').value = rating;
        for (var i = 1; i <= 5; i++)
            if (i <= rating)
                document.getElementById('star' + i).setAttribute('src', '../../Images/yellowStar.png')
            else
                document.getElementById('star' + i).setAttribute('src', '../../Images/whiteStar.png')
    }

    function Rating() {
        var xmlhttp;
        if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        }
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4) {
                document.getElementById("userReview").innerHTML = xmlhttp.responseText;
            }
        }
        xmlhttp.open("GET", "../Rate?rating=" + document.getElementById("rating").value + "&gameId=" +
            document.getElementById("gameId").value, true);
        xmlhttp.send();
    } 
</script>
</head>

    <h1 class="title @Html.GetColor(Request.Cookies["color"])">@Model.Name</h1>
<div id="titlelessItem">
<div class="item">
    @ViewBag.Name

    <div class="descBox descBlack">@Model.Description</div>

    <br />
    <div id="userReview"></div>
    <div class="Rating">
      <img id="star1" src="../../Images/whiteStar.png" alt="Rating" height="42" width="50" onclick="Rate(1)"/>
      <img id="star2" src="../../Images/whiteStar.png" alt="Rating" height="42" width="50" onclick="Rate(2)"/>
      <img id="star3" src="../../Images/whiteStar.png" alt="Rating" height="42" width="50" onclick="Rate(3)"/>
      <img id="star4" src="../../Images/whiteStar.png" alt="Rating" height="42" width="50" onclick="Rate(4)"/>
      <img id="star5" src="../../Images/whiteStar.png" alt="Rating" height="42" width="50" onclick="Rate(5)"/><br/><br/><br/>
      <input id="rating" type="hidden" name="rating" />
      <input id="gameId" type="hidden" value="@Model.Id" />
      <input type="button" value="Rate"  onclick="Rating()" class="actionButtons @Html.GetColor(Request.Cookies["color"])"/>
    </div>

    @{
        Pro260Website.Models.VideoViewModel viewModel = new Pro260Website.Models.VideoViewModel()
        {
            YoutubeID = Model.YoutubeLink,
            VideoName = Model.FileName
        };

        Html.RenderPartial("VideoDisplay", viewModel);        
    }
    
        <div class="sideBox @Html.GetColor(Request.Cookies["color"])" style="padding: 15px; width: 63%;">
                    
        @if(User.Identity.Name != "")
        {
            @Html.ActionLink("Create Review", "CreateReview", "Review", new { gameId = Model.Id }, new { @class = "actionButtons " + @Html.GetColor(Request.Cookies["color"]) })
        }

        @if (Model.Articles.Any())
        {
            @Html.ActionLink("News", "ViewGameNews", "News", new { gameId = Model.Id }, new { @class = "actionButtons " + @Html.GetColor(Request.Cookies["color"]) })
        }
    </div>

    @if (Model.SystemRequirements != null)
    {
        <h2 class="title @Html.GetColor(Request.Cookies["color"])">System Requirements</h2>
        <p class="descBackground" id="systemRequirements">
            <em>OS:</em> @Model.SystemRequirements.OS     <br />
            <em>Video Card:</em> @Model.SystemRequirements.VideoCard    <br />
            <em>Processor:</em> @Model.SystemRequirements.Processor    <br />
            <em>Memory:</em> @Model.SystemRequirements.Memory
        </p>
    }

    
    <div>
    @using (Html.BeginForm("AmazonSearch", "Search"))
    {
        <input type="hidden" name="searchItem" value="@Model.Name" />
        <input type="submit" value="Search Amazon" class="actionButtons @Html.GetColor(Request.Cookies["color"])"/>
    }
    @using (Html.BeginForm("GamestopSearch", "Search"))
    {
        <input type="hidden" name="searchItem" value="@Model.Name" />
        <input type="submit" value="Search Gamestop" class="actionButtons @Html.GetColor(Request.Cookies["color"])"/>
    }
    @using (Html.BeginForm("GoogleShoppingSearch", "Search"))
    {
        <input type="hidden" name="searchItem" value="@Model.Name" />
        <input type="submit" value="Search Google Shopping" class="actionButtons @Html.GetColor(Request.Cookies["color"])"/>
    }
    </div>
    </div>
</div>
